package com.sky_dreaming.mvp;

import library.base.BaseApplication;
import library.base.GlobalField;
import library.net.RxRetrofitUtils;
import library.net.retrofit.cache.RxCacheProvider;
import library.net.retrofit.okhttp.RxOkHttpBuilder;
import library.router.Router;

/**
 * @author Created by qiang.hou on 2018/3/2.
 * @version 1.0
 */
public class MyApplication extends BaseApplication {
    @Override
    public void onCreate() {
        super.onCreate();
    }

    public static MyApplication application() {
        return (MyApplication) getInstance();
    }

    @Override
    protected String defineSharedPreferenceName() {
        return GlobalField.SHARED_PREFERENCE_NAME;
    }

    @Override
    protected String[] defineModulesNeedManagedByModuleName() {
        return new String[0];
    }

    @Override
    public void initRouter() {
        Router.getInstance().init(BuildConfig.DEBUG, this);
    }

    @Override
    public void initNetworkConfig() {
        RxRetrofitUtils.getInstance()
                .baseUrl("http://xx.xx.xx.xxx/")
                .httpClient(new RxOkHttpBuilder()
                        .cache(RxCacheProvider.cache(getBaseContext()))
//                        .interceptor(new TokenInterceptor())
                        .build())
                .init(this);
    }

    @Override
    public void initOtherConfig() {
    }
}
